package org.geohunter.activity.map;

import org.geohunter.R;
import org.geohunter.activity.main.SwitchableMapTab;
import org.geohunter.menuactions.MenuAction;
import org.geohunter.menuactions.StaticLabelMenu;

import android.content.res.Resources;

import java.util.prefs.Preferences;

public class MenuActionMapType extends StaticLabelMenu implements MenuAction {
    private final Preferences mPreferences;
    private final SwitchableMapTab mSwitchableMapTab;
    
    public MenuActionMapType(Resources resources, Preferences preferences,
            SwitchableMapTab switchableMapTab) {
        super(resources, R.string.menu_map_source);
        mPreferences = preferences;
        mSwitchableMapTab = switchableMapTab;
    }

    /** Sets the previously chosen or the default map */
    public void initMap() {
        String type = mPreferences.get("map_type", "google");
        if (type.equals("google")) {
            mSwitchableMapTab.showTab(SwitchableMapTab.GOOGLE);
        } else if (type.equals("osm")) {
            mSwitchableMapTab.showTab(SwitchableMapTab.OSM);
        }
    }
    
    @Override
    public void act() {
        
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}
